<template>
  <div>
    <el-table
      :data="cateList"
      style=  "width: 100%"
      border
      row-key="id"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      
    >
      <el-table-column prop="id" label="分类编号"></el-table-column>
      <el-table-column prop="catename" label="分类名称"></el-table-column>
      <el-table-column label="图片">
        <template slot-scope="scope">
          <img :src="$pre+scope.row.img" alt v-if="scope.row.img">
        </template>
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" @click="start(scope.row.id)">启用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="change(scope.row.id)">编辑</el-button>
          <v-delete @del="del(scope.row.id)"></v-delete>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapGetters, mapActions } from "vuex";
import { cateDel } from "../../../request/api";
export default {
  data() {
    return {};
  },
  props: ["flag"],
  computed: {
    ...mapGetters({
      cateList: "cate/cateList"
    })
  },
  components: {},
  methods: {
    ...mapActions({
      reqCateList: "cate/reqCateList",
      reqCateInfo:"cate/reqCateInfo"
    }),
    //启动
    start() {},
    //编辑
    change(id) {
      this.flag.isShow = true
      this.flag.isAdd = false
      this.reqCateInfo(id);
    },
    //删除
    del(id) {
      cateDel({ id: id });
      this.reqCateList();
    },
  
  },
};
</script>
<style lang='less' scoped>
img {
  width: 100px;
  height: 100px;
}
</style>